from ultralytics import YOLO

if __name__ == '__main__':

    # 定义保存路径
    save_dir = 'train_results'

    # Load a model
    model = YOLO(model=r'D:\zzj\yolo\ultralytics-main\train_results\0718smoke_img182_epoch300_imgsz680_batch8_yolov11s\weights\best.pt')  
    model.predict(source=r'D:\zzj\zzjTools\video_smoke\test2.png',
                  save=True,
                  show=True,
                  project=save_dir,  # 保存项目目录
                  name='predict_output/smoke',  # 保存的子目录名称
                  exist_ok=True,  # 如果目录已存在，则覆盖
                  )
